<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="${ctx}/css/common.css" />
<jsp:include page="../inc.jsp"></jsp:include>
	<jsp:include page="../head.jsp"/>
<meta http-equiv="X-UA-Compatible" content="edge" />
<title>出票信息</title>
<style>
		input{
			width:120px;
			height:18px;
			border:1px solid #77b2e0;
			border-radius: 3px;
		}
		select{
			height:20px;
			border:1px solid #77b2e0;
			border-radius: 3px;
		}
		.searchBox{
			width:1200px; 
			height:45px;
		}
		.searchBox li{
			float:left;
			margin-top:5px;
			margin-left:15px;
		}
		.tableOntab td{
			height:37px;
			border-right:none;
		}
		.tableOntab .borderNone{
			border-bottom:none;
		}
		.query{
			margin-left:5px;
		}
		/*使按钮居中*/
		.autoBoxTwo{
			width:180px;
			height:26px;
			margin:15px auto; 
		}
		input::-ms-clear{display:none;}
</style>

<script type="text/javascript">
	$(function(){
		//加载表格信息
		dataGrid = $('#ticketTable').datagrid({
			url:'${ctx}/search/getBuyerList?temp='+Math.random(),
			//url:'${ctx}/json/ticketInfo.json',
			striped : true,
			singleSelect : true,
			idField : 'id',
			pageList : [5,10,20],
			//sortName : 'id',
			//sortOrder : 'asc',
			method : 'get',
			toolbar:'#toolbar',
			pagination:true,
			sortName:'toStartDate',
			sortOrder:'asc',
			columns:[[
			          {
							width : '80',
							title : 'id',
							field : 'id',
							hidden : true,
						},{
							width : '220',
							title : '订单号',
							align : 'center',
							field : 'orderNumber',
							sortable : true,
						},{
				width : '120',
				title : '航班号',
				align : 'center',
				field : 'airlineId',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:120px;"><tr><td>'+((row.list))[0].airlineNumber+'</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:120px;"><tr><td>'+((row.list))[0].airlineNumber+'</td>'+'</tr><tr>'+'<td class="borderNone">'+((row.list))[1].airlineNumber+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '150',
				title : '出发',
				align : 'center',
				field : 'charterTypeStr',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:150px;"><tr><td>'+(row.list)[0].deptCity+'('+(row.list)[0].deptCode+')</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:150px;"><tr><td>'+(row.list)[0].deptCity+'('+(row.list)[0].deptCode+')'+'</td>'+'</tr><tr>'+'<td class="borderNone">'+(row.list)[1].deptCity+'('+(row.list)[1].deptCode+')'+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '150',
				title : '到达',
				align : 'center',
				field : 'scheduleId',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:150px;"><tr><td>'+(row.list)[0].arrCity+'('+(row.list)[0].arrCode+')</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:150px;"><tr><td>'+(row.list)[0].arrCity+'('+(row.list)[0].arrCode+')'+'</td>'+'</tr><tr>'+'<td class="borderNone">'+(row.list)[1].arrCity+'('+(row.list)[1].arrCode+')'+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '120',
				title : '出发日期',
				align : 'center',
				field : 'scheduleIdStr',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:120px;"><tr><td>'+(row.list)[0].deptDate+'</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:120px;"><tr><td>'+(row.list)[0].deptDate+'</td>'+'</tr><tr>'+'<td class="borderNone">'+(row.list)[1].deptDate+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '55',
				title : '出发时刻',
				align:'center',
				field : 'journeyType',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:50px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].deptTime)+'</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:50px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].deptTime)+'</td>'+'</tr><tr>'+'<td class="borderNone">'+CommonConverter.formatFlightTime((row.list)[1].deptTime)+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '55',
				title : '到达时刻',
				align:'center',
				field : 'toDate',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						
						if(row.list.length == 1){
							var backIntervalDay=(row.list)[0].intervalDay;
							var _backIntervalDay="";
							if (backIntervalDay >= 1){
								_backIntervalDay="+"+backIntervalDay;
							}; 
							table='<table class="tableOntab" style="width:50px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].arrTime)+_backIntervalDay+'</td></tr></table>';
						}else if(row.list.length == 2){
							var toIntervalDay=(row.list)[0].intervalDay;
							var backIntervalDay=(row.list)[1].intervalDay;
							var _toIntervalDay="";
							var _backIntervalDay="";
							if (toIntervalDay >= 1){
								_toIntervalDay="+"+toIntervalDay;
							}; 
							if (backIntervalDay >= 1){
								_backIntervalDay="+"+backIntervalDay;
							}; 
							table='<table class="tableOntab" style="width:50px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].arrTime)+_toIntervalDay+
							'</td>'+'</tr><tr>'+'<td class="borderNone">'+CommonConverter.formatFlightTime((row.list)[1].arrTime)+_backIntervalDay+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '100',
				title : '状态',
				align:'center',
				field : 'orderStatus',
				formatter:function(value,row){
					return CommonConverter.toOrderBizStatusStr(row.orderStatus);
				}
			},{
				width : '100',
				title : '单价(CNY)',
				align:'center',
				field : 'sellingPrice',
			},{
				width : '100',
				title : '数量',
				align:'center',
				field : 'purchQuantity',
			},{
				width : '100',
				title : '总价',
				align:'center',
				field : 'sum',
			}
			] ]
		});
		//点击查询 重新加载列表
		$("#query").click(function(){
			//出发到达城市清空处理
			alsoempty($("#homecity_name"),$("#_startCity"));
			alsoempty($("#getcity_name"),$("#_endCity"));
			//获取参数
			var orderNumber=$("#_orderNumber").val();
			var orderStatus=$("#orderStatus").val(); //出票状态
			var toStartAirportCode=$("#_startCity").val(); //去程 出发机场三字码
			var toEndAirportCode=$("#_endCity").val(); // 去程  到达机场三字码
			var toStartDate=$("#_startTime").datebox('getValue'); //去程出发时间
			if(typeof(toStartAirportCode) == 'undefined'){
				toStartAirportCode = "";
			}
			if(typeof(toEndAirportCode) == 'undefined'){
				toEndAirportCode = "";
			}
			$('#ticketTable').datagrid('load',{"orderNumber":orderNumber,"orderStatus":orderStatus,"toStartAirportCode":toStartAirportCode,"toEndAirportCode":toEndAirportCode,"toStartDate":toStartDate,"temp":Math.random()});
			//$('#orderTable').datagrid('load',queryVo);
		});
		
	});
	
	//如果为空  对应的文本框为空
	function alsoempty(a,b){
		if(a.val() == "中文/拼音"){
			b.val("");
		};
	};
</script>
</head>
<body style="padding-left:10px;padding-top:10px;">
	<div>
		 <div>
			<ul class="searchBox">
					<li>订单号：<input style='width:120px;' class="easyui-textbox" id="_orderNumber" /></li>
					<li>
						出票状态：
						<select id="orderStatus" style="width: 73px;">
							<option value="-1">全部</option>
							<option value="0">待支付</option>
							<option value="2">待出票</option>
							<option value="4">出票完成</option>
							<option value="5">已取消</option>
						</select>
					</li>
					<li>去程出发：
					<input type="text" value="" size="15" id="homecity_name" name="homecity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel" mod_address_suggest="" mod_address_reference="_startCity" mod_notice_tip="中文/拼音" />
					<input id="_startCity" name="_startCity" type="hidden" value="" />
					</li>
					<li>去程到达：
					<input type="text" value="" size="15" id="getcity_name" name="getcity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel"  mod_address_reference="_endCity" mod_notice_tip="中文/拼音" />
					<input id="_endCity" name="_endCity" type="hidden" value="" />
					</li>
					<li>
						去程出发时间 ：<input class="easyui-datebox" id="_startTime" style="width: 120px" />
					</li>
					<li><button class='query' id="query">查询</button></li>
				</ul>
			</div>
			 <div>
				<table id="ticketTable" class="easyui-datagrid"></table>
			</div>
		</div>
<script type="text/javascript" src="${ctx }/jslib/airport/fixdiv.js"></script>
<script type="text/javascript" src="${ctx }/jslib/airport/address.js"></script>
<jsp:include page="../footer.jsp"/>
</body>
</html>